﻿
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NetCore.BLL;
using NetCore.Model;
namespace NetCore.Member.Web.Controllers
{
    [MenuPage(40, "040", "基本信息", "member/info", "fa-user")]
    [Authorize]
    public class InfoController : AreaController
    {
        public IUserService mService { get; set; }
        public IActionResult Index(UserEntity entity)
        {
            if (!this.IsPost)
            {
                if (!string.IsNullOrEmpty(this.UserId))
                {
                    entity = mService.GetById(this.UserId);
                }
                if (entity == null)
                {
                    entity = new UserEntity
                    {

                    };
                }
            }
            else
            {
                string strError = "";
                if (ModelState.IsValid)
                {
                    if (mService.Save(entity, ref strError))
                    {
                        return RedirectToAction("Index");
                    }
                    ModelState.AddModelError(string.Empty, strError);
                }

            }

            return View(entity);
        }

      
     
    }
}
